CREATE TRIGGER DistinctPatient
ON Patient FOR INSERT,UPDATE AS

BEGIN
	DECLARE @name VARCHAR(100)
	DECLARE @age INT
	DECLARE @address VARCHAR(100)

	SET @name = (SELECT name FROM INSERTED)
	SET @age = (SELECT age FROM INSERTED)
	SET @address = (SELECT address FROM INSERTED)

	IF ((SELECT COUNT(*)
		 FROM Patient
		WHERE name = @name
		  AND age = @age
		  AND address = @address) > 1)
	BEGIN
		PRINT 'Duplicate patient.'
		ROLLBACK
	END
END